﻿namespace WindowsFormsApplication1
{
    public class FPAPI
    {
        #region 函数执行结果代码(错误代码)

        /// <summary>
        /// 成功
        /// </summary>
        public const int F_OK = 0;

        /// <summary>
        /// 传入的参数或指针为NULL
        /// </summary>
        public const int FP_PARAMETER_NULL = -1000;

        /// <summary>
        /// COM组件没有注册
        /// </summary>
        public const int FP_COM_UNREGISTER = -1001;

        /// <summary>
        /// clsid string格式错误，不能转为clsid
        /// </summary>
        public const int FP_CLSID_INVALIDARG = -1002;

        /// <summary>
        /// 创建COM组件对象失败
        /// </summary>
        public const int FP_COM_CREATEFAILURE = -1003;

        /// <summary>
        /// 内存不足，即内存申请失败
        /// </summary>
        public const int FP_MEMORY_FAILURE = -1004;

        /// <summary>
        /// 设备没有选择
        /// </summary>
        public const int FP_DEVICE_NOSELECT = -1005;

        /// <summary>
        /// sensor没有选择
        /// </summary>
        public const int FP_SENSOR_NOSELECT = -1006;

        /// <summary>
        /// setparameter错误,参数不存在
        /// </summary>
        public const int FP_PARAMETER_NOEXIST = -1007;

        /// <summary>
        /// setparameter错误,值越界
        /// </summary>
        public const int FP_VALUE_OUT = -1008;

        /// <summary>
        /// setparameter错误,type越界，即不存在
        /// </summary>
        public const int FP_TYPE_OUT = -1009;

        /// <summary>
        /// veirfy 没有权限，即lic无效
        /// </summary>
        public const int FP_LICENSE_INVALID = -1010;

        /// <summary>
        /// getparameter 没有权限
        /// </summary>
        public const int FP_ACCESS_ERROR = -1011;

        /// <summary>
        /// CreateEvent失败，设备已经启动，不能多个实例
        /// </summary>
        public const int EVENT_ALREADY_EXIST = 2000;

        /// <summary>
        /// 线程创建失败
        /// </summary>
        public const int THREAD_CREATE_FAILURE = -2001;

        /// <summary>
        /// 设备不存在
        /// </summary>
        public const int DEVICE_CHECK_NOEXIST = -2003;

        /// <summary>
        /// 设备打开失败，一般设备没有找到，或驱动方面有问题
        /// </summary>
        public const int DEVICE_OPEN_FAILURE = -2004;

        /// <summary>
        /// 设备关闭失败
        /// </summary>
        public const int DEVICE_CLOSE_FAILURE = -2005;

        /// <summary>
        /// 开始取图失败（SetEvent 失败）
        /// </summary>
        public const int EVENT_SET_FAILURE = -2006;

        /// <summary>
        /// 设备启动失败，RPC服务没有处于监听，请修复驱动或者关闭对应的防火墙（FRO500）
        /// </summary>
        public const int SERVICE_STARTRPC_FAILURE = -2007;

        /// <summary>
        /// FX_init初始化的时候内存不足
        /// </summary>
        public const int DEVICE_DP001_NO_MEMORY = -2008;

        /// <summary>
        /// FX_init初始化的时候setting有错误
        /// </summary>
        public const int DEVICE_DP001_BAD_SETTING = -2009;

        /// <summary>
        /// FX_createContext创建失败
        /// </summary>
        public const int DEVICE_DP001_CREATECONTEXT_FAILURE = -2010;

        /// <summary>
        /// DPFPCreateAcquisition 失败，权限不够
        /// </summary>
        public const int ACQUISITION_ACCESSDENIED = -2011;

        /// <summary>
        /// DPFPCreateAcquisition 失败，参数有误
        /// </summary>
        public const int ACQUISITION_INVALIDARG = -2012;


        /// <summary>
        /// DPFPCreateAcquisition 失败
        /// </summary>
        public const int ACQUISITION_FAILURE = -2013;

        /// <summary>
        /// 不支持同时启动多个sensor
        /// </summary>
        public const int DEVICE_MUTIPLESENSORS_NOSPPORT = -2014;

        /// <summary>
        /// 不支持对同一sensor进行多个应用程序的访问
        /// </summary>
        public const int DEVICE_SAMETIMEENROLL_NOSPPORT = -2015;

        /// <summary>
        /// SENSOR_BUSY	-2016	开始获取图像失败...当前正在获取图像中...
        /// </summary>
        public const int SENSOR_BUSY = -2016;

        /// <summary>
        /// sensor COM一个也没安装
        /// </summary>
        public const int DEVICECONTROL_COM_NOEXIST = -3000;

        /// <summary>
        /// 设备没有插入电脑中，一个也没检索到
        /// </summary>
        public const int DEVICECONTROL_DEVICE_NOEXIST = -3001;

        /// <summary>
        /// 注册表信息读取失败
        /// </summary>
        public const int DEVICECONTROL_READINFO_FAILURE = -3002;

        /// <summary>
        /// 传入的参数或指针为NULL
        /// </summary>
        public const int FA_PARAMETER_NULL = -4000;


        /// <summary>
        /// 获取指定结果的错误描述
        /// </summary>
        /// <param name="resultCode">错误编码</param>
        /// <returns>错误描述</returns>
        public static string GetResult(int resultCode)
        {
            string errTxt = "";
            switch (resultCode)
            {
                case -1000:
                    errTxt = "传入的参数或指针为NULL";
                    break;
                case -1001:
                    errTxt = "COM组件没有注册";
                    break;
                case -1002:
                    errTxt = "clsid string格式错误，不能转为clsid";
                    break;
                case -1003:
                    errTxt = "创建COM组件对象失败";
                    break;
                case -1004:
                    errTxt = "内存不足，内存申请失败";
                    break;
                case -1005:
                    errTxt = "设备没有选择";
                    break;
                case -1006:
                    errTxt = "sensor没有选择";
                    break;
                case -1007:
                    errTxt = "设置参数错误,参数不存在";
                    break;
                case -1008:
                    errTxt = "设置参数错误,值越界";
                    break;
                case -1009:
                    errTxt = "设置参数错误,参数类型不存在";
                    break;
                case -1010:
                    errTxt = "没有比对权限，指纹仪系统验证许可无效";
                    break;
                case -1011:
                    errTxt = "没有获取参数的权限";
                    break;
                case -2000:
                    errTxt = "设备已经启动，不能启动多个实例";
                    break;
                case -2001:
                    errTxt = "线程创建失败";
                    break;
                case -2002:
                    errTxt = "设备不存在";
                    break;
                case -2004:
                    errTxt = "设备打开失败，一般设备没有找到，或驱动方面有问题";
                    break;
                case -2005:
                    errTxt = "设备关闭失败";
                    break;
                case -2006:
                    errTxt = "开始取图失败";
                    break;
                case -2007:
                    errTxt = "设备启动失败，RPC服务没有处于监听，请修复驱动或者关闭对应的防火墙";
                    break;
                case -2008:
                    errTxt = "初始化的时候内存不足";
                    break;
                case -2009:
                    errTxt = "初始化的时候设置有错误";
                    break;
                case -2010:
                    errTxt = "FX_createContext创建失败";
                    break;
                case -2011:
                    errTxt = "DPFPCreateAcquisition 失败，权限不够";
                    break;
                case -2012:
                    errTxt = "DPFPCreateAcquisition 失败，参数有误";
                    break;
                case -2013:
                    errTxt = "DPFPCreateAcquisition 失败";
                    break;
                case -2014:
                    errTxt = "不支持同时启动多个sensor";
                    break;
                case -2015:
                    errTxt = "不支持对同一sensor进行多个应用程序的访问";
                    break;
                case -2016:
                    errTxt = "开始获取图像失败...当前正在获取图像中...";
                    break;
                case -3000:
                    errTxt = "ensor COM一个也没安装";
                    break;
                case -3001:
                    errTxt = "设备没有插入电脑中，一个也没检索到";
                    break;
                case -3002:
                    errTxt = "注册表信息读取失败";
                    break;
                case -4000:
                    errTxt = "传入的参数或指针为NULL";
                    break;
                default:
                    errTxt = "成功";
                    break;
            }

            return errTxt;
        }
        #endregion
    }
}
